
var MDBOp = {
	subSys:'',
	mdbopID:'',
	mdbopRes:null,
	formTables:null,
	pDialog:null,
	init:function(){
		if(funcUrl==""){
			System.showError('错误', "系统错误：报表功能insert的类型为用户自定义，必须提供功能URL!");
			top.$.messager.progress('close');
			return;
		}
		var subSys = System.getRequest("subSys",funcUrl);
		var mdbopID = System.getRequest("mdbopID",funcUrl);
		var dlgId = System.getRequest("dlgId",location.href);
		top.$.messager.progress('close');
		if(!subSys||!mdbopID){
			System.showError('错误', "系统错误：新增URL中必须提供subSys及insertID参数值!");
			return;
		}
		MDBOp.subSys = subSys;
		MDBOp.mdbopID = mdbopID;
		if(dlgId){
			MDBOp.pDialog = System.getCache(dlgId);
		}
		if(!MDBOp.pageInfo()){
			return;
		}
		MDBOp.initPage();
		MDBOp.initForm();
	},
	pageInfo:function(){
		var result = false;
		var url = System.getRootPath()+"/"+funcUrl;
		System.ajaxGet(url,function(data){
			if(data.result=='error'){
				System.showError('错误', data.message);
				result = false;
			}else{
				MDBOp.subSys = data.subSys;
				MDBOp.mdbopID = data.mdbopId;
				MDBOp.mdbopRes = data.mdbopRes;
				MDBOp.formTables = data.formTables;
				result = true;
			}
		},false);
		return result;
	},
	initPage:function(){
		if(!MDBOp.mdbopRes){
			return;
		}
		var pageTitle = MDBOp.mdbopRes.resDesc;
		if(MDBOp.pDialog){
			MDBOp.pDialog.dialog('setTitle',pageTitle);
		}
	},
	initForm:function(){
		var _formId = 'insForm';
		MDBOp.createForm(_formId);
		Form.formId = _formId;
		Form.formType = 'ins';
		Form.formTables = MDBOp.formTables;
		Form.init();
		MDBOp.initFun();
		
		/*
		var _formId = 'mDBOpForm';
		MDBOp.createForm(_formId);
		Form.formId = _formId;
		Form.formType = 'ins';
		Form.fieldNamePre = 'col_';
		Form.fields = Insert.fields;
		Form.resObj = Insert;
		Form.dicsMap = Insert.dicsMap;
		Form.init();
		Insert.initFun();
		*/
	},
	createForm:function(formId){
		var _formHtml = "<form id=\""+formId+"\" method=\"post\">";
		_formHtml += "</form>";
		$('div.easyui-layout').layout('panel','center').html(_formHtml);
		MDBOp.form = $('form');
	},
	initFun:function(){
		var _funArea = "<div style=\"text-align: center; padding: 5px;\">";
		_funArea += "<a id=\"btnEp\" class=\"easyui-linkbutton\" icon=\"icon-ok\" href=\"javascript:MDBOp.submit();\" >保存</a> ";
		_funArea += "<a id=\"btnCancel\" class=\"easyui-linkbutton\" icon=\"icon-cancel\" href=\"javascript:MDBOp.closeWin();\">关闭</a>";
		_funArea += "</div>";
		$('div.easyui-layout').layout('add',{    
			region: 'south',    
			border:false,
			content:_funArea,
			height:40
		});
	},
	closeWin:function(){
		if(MDBOp.pDialog){
			MDBOp.pDialog.dialog('close');
		}
	},
	submit:function(){
		if(!Form.validate()){
			return;
		}
		var dataJson = Form.getFormData();
		return;
		/*
		MDBOp.form.form('submit', {
			url: System.getRootPath()+'/sysmng.insert.do?subSys='+MDBOp.subSys+"&mdbopID="+MDBOp.mdbopID,
			onSubmit: function () {
				var validateResult = Form.validate();
//				var validateResult = $(this).form('validate');
				console.info(validateResult);
				return validateResult;
			},
			success: function (data) {
				
			}
		});
		*/
	}
}